﻿using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
using System.IO;

namespace ListenerServer
{
    class Program
    {
        static void Main(string[] args)
        {
            //create listener socket
            IPHostEntry ipHost = Dns.GetHostEntry(""); 
            IPAddress ipAddr = ipHost.AddressList[0]; 
            IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 3000);

            Socket listenerSocket = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            listenerSocket.Bind(ipEndPoint);
            listenerSocket.Listen(10);


            //wait for client connections and serve each client by new thread.
            while (true)
            {
                Socket clientSocket = listenerSocket.Accept();
                Client client = new Client();
                client.Start(clientSocket);
            }
        }

        
    }
}
